// 定义路由映射表
import { lazy } from 'react'
import { Navigate } from 'react-router-dom';
import {
    AppstoreOutlined,
    ContainerOutlined,
    DesktopOutlined,
    MailOutlined,
    MenuFoldOutlined,
    MenuUnfoldOutlined,
    PieChartOutlined,
} from '@ant-design/icons';

// 引入路由组件
// 首页组件
const Home = lazy(() => import('@/views/layout/home/Home'))
// 账户管理组件
const Account = lazy(() => import('@/views/layout/account/Index'))
const Adminlist = lazy(() => import('@/views/layout/account/Adminlist'))
// 轮播图管理组件
const Banner = lazy(() => import('@/views/layout/banner/Index'))
const Bannerlist = lazy(() => import('@/views/layout/banner/Bannerlist'))
const AddBanner = lazy(() => import('@/views/layout/banner/Addbanner'))
// 产品管理组件
const Product = lazy(() => import('@/views/layout/product/Index'))
const Productlist = lazy(() => import('@/views/layout/product/Productlist'))
const Productfilterlist = lazy(() => import('@/views/layout/product/Productfilter'))
const Productrecommendlist = lazy(() => import('@/views/layout/product/Productrecommend'))
const Productseckill = lazy(() => import('@/views/layout/product/Productseckill'))
// 系统设置
const Setting = lazy(() => import('@/views/layout/setting/Index'))
// 引入404 组件
const Notfind = lazy(() => import('@/views/Notfind'))


const routes = [
    {
        path: '/home',
        element: <Home></Home>,
        label: '系统首页',
        key: '/home',
        icon: <PieChartOutlined />
    },
    {
        path: '/account',
        element: <Account></Account>,
        label: '账户管理',
        key: '/account',
        icon: <ContainerOutlined />,
        children: [
            {
                path: '/account/adminlist',
                element: <Adminlist />,
                label: '管理员列表',
                key: '/account/adminlist',
                icon: <DesktopOutlined />
            }
        ]
    },
    {
        path: '/banner',
        element: <Banner></Banner>,
        label: '轮播图管理',
        key: '/banner',
        icon: <MailOutlined />,
        children: [
            {
                path: '/banner/bannerlist',
                element: <Bannerlist />,
                label: '轮播图列表',
                key: '/banner/bannerlist',
                icon: <MenuFoldOutlined />,
            },
            {
                path: '/banner/addbanner',
                element: <AddBanner />,
                label: '添加轮播图'  // 因为需要显示面包屑
            }
        ]
    },
    {
        path: '/product',
        element: <Product></Product>,
        label: '产品管理',
        key: '/product',
        icon: <MenuFoldOutlined />,
        children: [
            {
                path: '/product/productlist',
                element: <Productlist />,
                label: '产品列表',
                key: '/product/productlist',
                icon: <MenuFoldOutlined />,
            },
            {
                path: '/product/filterlist',
                element: <Productfilterlist />,
                label: '筛选列表',
                key: '/product/filterlist',
                icon: <MenuFoldOutlined />,
            },
            {
                path: '/product/recommendllist',
                element: <Productrecommendlist />,
                label: '推荐列表',
                key: '/product/recommendllist',
                icon: <MenuFoldOutlined />,
            },
            {
                path: '/product/seckilllist',
                element: <Productseckill />,
                label: '秒杀列表',
                key: '/product/seckilllist',
                icon: <MenuFoldOutlined />,
            }
        ]
    },
    {
        path: '/setting',
        element: <Setting />,
        label: '系统设置',
        key: '/setting',
        icon: <MenuUnfoldOutlined />
    },
    {
        path: '*', // 404 路由
        element: <Notfind />,
    }
];


export default routes